<%
var headerPart = {
%>
<script type="text/javascript">
    $(document).ready(function(){
    });
    function page(n,s){
        location = '${ctx}/act/process/?pageNo='+n+'&pageSize='+s;
    }
    function updateCategory(id, category){
        layui.use(['form'],function () {
            var form = layui.form;
            layer.open({
                type: 1,
                title: '设置分类',
                area: ['400px', '280px'], //宽高
                content: $("#categoryBox").html(),
                btn:['关闭']
            });
            form.render('select');
        });
        $("#categoryBoxId").val(id);
        $("#categoryBoxCategory").val(category);
    }
</script>
<script type="text/template" id="categoryBox">
	<form id="categoryForm" action="${ctx}/act/process/updateCategory" method="post" enctype="multipart/form-data"
		  class="layui-form" onsubmit="layer.load(0, {shade: false});"><br/>
		<input id="categoryBoxId" type="hidden" name="procDefId" value="" />
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">分类：</label>
				<div class="layui-input-inline">
					<select id="categoryBoxCategory" name="category">
						<option value="">无分类</option>
						<#options items="${@DictUtils.getDictList('act_category')}" value=""/>
					</select>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<input id="categorySubmit" class="layui-btn btn-primary" type="submit" value="保存"/>　
			</div>
		</div>　
	</form>
</script>
<% }; %>
<% layout("/layouts/micro.html",{headerSection:headerPart}){ %>
<div class="layui-tab layui-tab-brief childrenBody">
	<ul class="layui-tab-title">
		<li class="layui-this"><a href="${ctx}/act/process/">流程管理</a></li>
		<li><a href="${ctx}/act/process/deploy/">部署流程</a></li>
		<li><a href="${ctx}/act/process/running/">运行中的流程</a></li>
	</ul>
	<div class="layui-tab-content">
	<form id="searchForm" action="${ctx}/act/process/" method="post" class="layui-form">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		
		<div class="layui-input-inline">
			<select id="category" name="category" class="input-medium">
				<option value="">全部分类</option>
				<#options items="${@DictUtils.getDictList('act_category')}" value="${category}"/>
			</select>
		</div>
		
		<div class="layui-input-inline">
			<input id="btnSubmit" class="layui-btn layui-btn-sm" type="submit" value="查询"/>
		</div>
	</form>
	<#message content="${message!}"/>
	<table class="layui-table" >
		<thead>
			<tr>
				<th style="text-align:center">流程分类</th>
				<th style="text-align:center">流程标识</th>
				<th style="text-align:center">流程名称</th>
				<th style="text-align:center">流程版本</th>
				<th style="text-align:center">部署时间</th>
				<th style="text-align:center">流程XML</th>
				<th style="text-align:center">流程图片</th>
				<th style="text-align:center">操作</th>
			</tr>
		</thead>
		<tbody>
			<%
				for(object in page.list){
					var process = object[0];
					var deployment= object[1];
			%>
				<tr>
					<td><a href="javascript:updateCategory('${process.id}', '${process.category}')" title="设置分类">${@DictUtils.getDictLabel(process.category,'act_category','无分类')}</a></td>
					<td>${process.key}</td>
					<td>${process.name}</td>
					<td><b title='流程版本号'>V: ${process.version}</b></td>
					<td>${deployment.deploymentTime,dateFormat="yyyy-MM-dd HH:mm:ss"}</td>
					<td><a target="_blank" href="${ctx}/act/process/resource/read?procDefId=${process.id}&resType=xml">${process.resourceName}</a></td>
					<td><a target="_blank" href="${ctx}/act/process/resource/read?procDefId=${process.id}&resType=image">${process.diagramResourceName}</a></td>
					<td>
						<%if(isEmpty(process.suspended)&&process.suspended==true){%>
							<a class="layui-btn layui-btn-xs" href="${ctx}/act/process/update/active?procDefId=${process.id}" onclick="return confirmx('确认要激活吗？', this.href)">激活</a>
						<%}else{%>
							<a class="layui-btn layui-btn-xs" href="${ctx}/act/process/update/suspend?procDefId=${process.id}" onclick="return confirmx('确认挂起除吗？', this.href)">挂起</a>
						<%}%>
						<a class="layui-btn layui-btn-xs layui-btn-danger" href='${ctx}/act/process/delete?deploymentId=${process.deploymentId}' onclick="return confirmx('确认要删除该流程吗？', this.href)">删除</a>
                        <a class="layui-btn layui-btn-xs" href='${ctx}/act/process/convert/toModel?procDefId=${process.id}' onclick="return confirmx('确认要转换为模型吗？', this.href)">转换为模型</a>
					</td>
				</tr>
			<%}%>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	</div>
</div>
<%}%>